﻿<UserControl x:Class="SilverPop.UI.Views.NoteCanvasView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
	xmlns:Controls="clr-namespace:SilverPop.UI.Controls">

	<Grid>
		<Grid.RowDefinitions>
			<RowDefinition Height="*"/>
		</Grid.RowDefinitions>
		<Grid.ColumnDefinitions>
			<ColumnDefinition Width="*"/>
			<ColumnDefinition Width="*"/>
		</Grid.ColumnDefinitions>

		<Controls:DiagramCanvas Padding="10" Margin="10"  
								ItemsSource="{Binding Notes}" 
								ClickCanvasCommand="{Binding CanvasClicked}"
								DeleteNodeCommand="{Binding DeleteNode}">

			<Controls:DiagramCanvas.Resources>
				<Controls:Divide2Converter x:Key="Divide2Converter"/>
			</Controls:DiagramCanvas.Resources>

			<Controls:DiagramCanvas.ItemTemplate>
				<DataTemplate>
					<Border 
						Width="{Binding W, Mode=TwoWay}" 
						Height="{Binding H, Mode=TwoWay}" 
						Canvas.Left="{Binding X, Mode=TwoWay}"
						Canvas.Top="{Binding Y, Mode=TwoWay}"
						Background="White" 
						BorderBrush="Black" 
						BorderThickness="3" 
						CornerRadius="10" 
						Padding="8,8,8,8">
						<Border.RenderTransform>
							<RotateTransform Angle="{Binding Angle, Mode=TwoWay}" 
											 CenterX="{Binding W, Converter={StaticResource Divide2Converter}}" 
											 CenterY="{Binding H, Converter={StaticResource Divide2Converter}}"/>
						</Border.RenderTransform>

						<TextBlock Text="{Binding Text}" TextAlignment="Center" TextWrapping="Wrap"/>
					</Border>
				</DataTemplate>
			</Controls:DiagramCanvas.ItemTemplate>
			<Controls:DiagramCanvas.AdornerTemplate>
				<DataTemplate>
					<Grid
						Width="{Binding W, Mode=TwoWay}" 
						Height="{Binding H, Mode=TwoWay}" 
						Canvas.Left="{Binding X, Mode=TwoWay}"
						Canvas.Top="{Binding Y, Mode=TwoWay}">
						<Grid.RenderTransform>
							<RotateTransform Angle="{Binding Angle, Mode=TwoWay}" 
											 CenterX="{Binding W, Converter={StaticResource Divide2Converter}}" 
											 CenterY="{Binding H, Converter={StaticResource Divide2Converter}}"/>
						</Grid.RenderTransform>
						<Border
							Background="White" BorderBrush="Black" BorderThickness="3" 
							CornerRadius="10" Padding="8,8,8,8">
							<TextBlock Text="{Binding Text, Mode=TwoWay}" TextAlignment="Center" TextWrapping="Wrap"/>
						</Border>

						<Rectangle Fill="Transparent"
									Stroke="Red"
									StrokeDashArray="2,1"
									StrokeThickness="2"
									Margin="-2,-2,-2,-2"/>

						<Line Stroke="Red" StrokeDashArray="2,1" StrokeThickness="2"
							HorizontalAlignment="Center" Y1="0" Y2="-50"/>

						<Thumb x:Name="ThumbTL" Margin="-10,-10,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Width="10" Height="10" />
						<Thumb x:Name="ThumbBL" Margin="-10,0,0,-10" HorizontalAlignment="Left" VerticalAlignment="Bottom" Width="10" Height="10" />
						<Thumb x:Name="ThumbTR" Margin="0,-10,-10,0" HorizontalAlignment="Right" VerticalAlignment="Top" Width="10" Height="10"/>
						<Thumb x:Name="ThumbBR" Margin="0,0,-10,-10" HorizontalAlignment="Right" VerticalAlignment="Bottom" Width="10" Height="10"/>
						<Thumb x:Name="ThumbROT" Margin="0,-50,0,0" HorizontalAlignment="Center" VerticalAlignment="Top" Width="10" Height="10"/>
						<Button x:Name="DeleteButton" HorizontalAlignment="Right" VerticalAlignment="Center" Content="X" Width="20" Margin="0,0,-20,0"/>

						<Canvas HorizontalAlignment="Center" VerticalAlignment="Bottom" 
								Margin="0,0,0,-70" Width="200" Height="60">
							<TextBox Text="{Binding Text, Mode=TwoWay}" Width="200" Height="150"/>
						</Canvas>

					</Grid>
				</DataTemplate>
			</Controls:DiagramCanvas.AdornerTemplate>
		</Controls:DiagramCanvas>

		<Controls:DiagramCanvas Padding="10" Margin="10" Grid.Column="1"
								ItemsSource="{Binding Notes}"
								ClickCanvasCommand="{Binding CanvasClicked}"
								DeleteNodeCommand="{Binding DeleteNode}"/>


	</Grid>
</UserControl>
